package com.yww.algorithm.recursion;

/**
 * @author yww
 * @description 递归反转字符串
 * @since 2024/1/31 11:30
 */
public class ReverseString {
    public static void reverse(int index, String str, StringBuilder sb) {
        if (index == str.length()) {
            return;
        }
        reverse(index + 1, str, sb);
        sb.append(str.charAt(index));
    }

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        reverse(0,"1234567",sb);
        System.out.println(sb.toString());
    }
}
